package com.ztz.mynewdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.ztz.mynewdemo.R;
import com.ztz.mynewdemo.bean.CollectResponse;

import java.util.List;

/**
 * Created by wqewqe on 2017/5/22.
 */

public class CollectAdapter extends BaseAdapter {
    Context context;
    List<CollectResponse> collectResponseList;

    public CollectAdapter(Context context, List<CollectResponse> collectResponseList) {
        this.context = context;
        this.collectResponseList = collectResponseList;
    }

    @Override
    public int getCount() {
        return collectResponseList.size();
    }

    @Override
    public Object getItem(int position) {
        return collectResponseList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view= LayoutInflater.from(context).inflate(R.layout.item_collecton,parent,false);
        ImageView iv=(ImageView)view.findViewById(R.id.iv_top);
        TextView title=(TextView)view.findViewById(R.id.top_title);
        TextView date=(TextView)view.findViewById(R.id.topLine_data);
        TextView category=(TextView)view.findViewById(R.id.tv_category);
        TextView author=(TextView)view.findViewById(R.id.tv_author);
        Glide.with(context).load(collectResponseList.get(position).getImage()).into(iv);
        title.setText(collectResponseList.get(position).getTitle());
        date.setText(collectResponseList.get(position).getDate());
        category.setText(collectResponseList.get(position).getCategory());
        author.setText(collectResponseList.get(position).getAuthor());
        return view;//view要返回
    }
}
